import React, { Component } from 'react'
import qs from 'qs'

const data = [
    { id: 1, content: "你好，中国" },
    { id: 2, content: "你好，学校" },
    { id: 3, content: "你好，未来" }
]

export default class Detail extends Component {
    render() {
        console.log(this.props);
        // const { id, title } = this.props.match.params                            // 接收params参数
        // const { id, title } = qs.parse(this.props.location.search.slice(1))      // 接收search参数
        const { id, title } = this.props.location.state || {}                          // 接收state参数

        const dataContent = data.find((item) => {
            return item.id == id
        }) || {}

        // console.log(dataContent);
        return (
            <ul>
                <li>ID:{id}</li>
                <li>TITLE:{title}</li>
                <li>CONTENT:{dataContent.content}</li>
            </ul>
        )
    }
}
